var Login = Vue.component('login', function (resolve, reject) {
    axios.get('views/login/login.html').then(function (res) {
        resolve({
            template: res.data,
            data(){
                return {
                    ruleForm2: {
                        username: '',
                        password: '',
                    },
                    rules2: {
                        username: [{required: true, message: 'please enter your account', trigger: 'blur'}],
                        password: [{required: true, message: 'enter your password', trigger: 'blur'}]
                    },
                    visible: false,
                    checked: false,
                    mainLogo:MAIN_INFO_CONFIG.mainLogo
                }
            },
            methods: {
                handleSubmit(){
                    // console.log(Loading);
                    this.$refs.ruleForm2.validate((valid) => {
                        if(valid){


                            httpInvoker.post(loginUrl,{'account':this.ruleForm2.username,'password':this.ruleForm2.password})
                                .then(res=>{
                                    if(res.status == 200 && res.data.status == '00'){
                                        sessionStorage.loginUser=JSON.stringify(res.data.data);
                                        if(CommonUtils.checkNotNull(sessionStorage.loginUser)){
                                            sessionStorage.token=res.data.data.token;
                                            axios.defaults.headers.token = sessionStorage.token;
                                        }
                                        this.$router.push({ path: '/main' });
                                    }else{
                                        this.$alert(res.data.msg, '', {
                                            confirmButtonText: '确定'
                                        });
                                    }
                                })
                        }else{
                            console.log('error submit!');
                            return false;
                        }
                    })
                }
            }
        })
    })
})